//
//  BaseButton.swift
//  DaRings
//
//  Created by 尹琼 on 2023/2/24.
//

import UIKit
import MYModule

class BaseButton: Button {
    
    
    override func sendAction(_ action: Selector, to target: Any?, for event: UIEvent?) {
        super.sendAction(action, to: target, for: event)
        
        setlogEvent()
    }
    
   open func setlogEvent() {
       
       guard let AppName = Bundle.main.infoDictionary?["CFBundleDisplayName"] as? String, AppName == "Da Rings" else {
           return
       }
        
        guard let type = self.itemNameType else {
            return
        }
        let envent = FireBaseEvent(select: .content, itemNameType: type)
        FireBaseManager.shared.logEvent(event: envent)
    }
    
    
   open var itemNameType: FireBaseEventItemNameType? {
        
        let title = self.title(for: .normal)
        
        if title == "workouts_records_start_workout_btn_title".language {
            
            return .Click_Home_Exercise_Record_Start_WorkOut
        }
        
        if title == "heart_rate_tap_to_measure_heart_rate".language {
            
            return .Click_Home_Heart_Rate_Start_Measurement
        }
        
        if title == "blood_oxygen_measure_star_btn_title".language {
            
            return .Click_Home_Blood_Oxygen_Saturation_Start_Measurement
        }
        
        if title == "hrv_tap_measure_btn_title".language {
            
            return .Click_Home_Heart_Rate_Variability_Start_Measurement
        }
        
        if title == "stress_measure_end_btn_title".language {
            
            return .Click_Home_Stress_Start_Measurement
        }
        
        if title == "device_add_btn_title".language {
            return .Click_Add_Device
        }
        
        if title == "tip_remove_device".language {
            return .Click_Remove_device
        }
        
        
        return nil
    }

}
